<template>
	<view>
		<view>
			<view class="title">
			 <view class="v1">首页</view>
			 <navigator class="v1" url="/homepky/Category/Category">文章分类</navigator>
			 <navigator class="v1" url="/homepky/Label/Label">标签</navigator>
			 <navigator class="v1" url="/domain/Publish/Publish">发布</navigator>
			</view>
			<scroll-view v-for="(item,i) in articleList" :key="i" class="vn2" scrolltolower="onReachBottom">
				<!-- <view class="v3"></view> -->
				<view  class="article">
					<!-- <view class="article-main"> -->
					<navigator :url="'/homepky/ArticleContent/ArticleContent?id='+ encodeURIComponent(JSON.stringify(item.id))">
						<view class="article-main">
							<view class="article-title">{{item.title}}</view>
							<view >{{item.summary}}</view>
						</view>
					</navigator>
					<view class="article-bottom">
						<view class="article-bottom-tag">
							<view v-for="(iom,u) in item.tags" :key="u" class="article-bottom-tag-size">{{iom.tagName}}</view>
						</view>
						<view  class="article-bottom-li" >
							<view style="display: flex;"><u-icon name="account-fill" /><view>{{item.author}}</view></view>
							<view style="display: flex;"><u-icon name="eye-fill" /><view>{{item.viewCounts}}</view></view>
							<view style="display: flex;"><u-icon name="clock-fill" /><view>{{item.createDate}}</view></view>
						</view>
					</view>
					<!-- </view> -->
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				articleList:[],
				articleListP:[],
				number:1
			};
		},
		onPullDownRefresh() {
		    this.getArticle1()
		    wx.stopPullDownRefresh();
		},
		onLoad() {
			this.getArticle()
		},
		methods:{
			async getArticle(number){
				// console.log(number);
				const { data : res} =await uni.$http.post('/articles',{
					page:number,
					pageSize:6,
				})
				if(res.code!==200) return uni.$showMsg()
				this.articleListP=res.data
				this.articleList=this.articleList.concat(this.articleListP)
				console.log(res);
				// .then((res) => {  
				//     // 处理成功响应  
				//     console.log(res); // 打印返回的数据  
				// }) 
			},
			onReachBottom: function () {
				var dd=this.number+1;
				this.number=dd;
				// console.log(dd);
				this.getArticle(dd)
			},
			async getArticle1(){
				const { data : res} =await uni.$http.post('/articles',{
					page:1,
					pageSize:6,
				})
				if(res.code!==200) return uni.$showMsg()
				this.articleList=res.data
				console.log(res);
				this.number=1
			},
		}
	}
</script>

<style lang="scss">
.title{
	display: flex;
	justify-content: space-around;
	background-color: #95aaa0;
	.v1{
		height: 30px;
		width: 100%;
		text-align: center;
	}
}
.article {
	padding: 13px;
	.article-main{
		display: flex;
		flex-direction: column;
		.article-title{
			// text-align: center;
			// 文字阴影 text-shadow:black 4px 4px 5px;
			font-size: 40rpx;
			font-weight: 900;
		}
	}
	.article-bottom{
		display: flex;
	    margin-top: 15px;
		position: relative;
		.article-bottom-li{
			display: flex;
			font-size: 25rpx;
			position: absolute;
			right: 2px;
			margin-top: 5px;
			.article-bottom-li-yuansu{
			}
		}
		.article-bottom-tag{
			display: flex;
			.article-bottom-tag-size{
				margin-left: auto;
				width:fit-content;
				height: auto;
				border-radius: 8rpx;
				background: #99a9bf;
				text-align: center;
			}
		}
		// margin-top: 10px;
		// justify-content: flex-end;
	}
}
.vn2{
	background-color: #ffffff;
	border: 2px solid #f0f0f0;
}
</style>
